import React, { useEffect, useState, useRef } from 'react';
import { getTableScroll } from '@/utils/tools';
import { Table, Empty } from 'antd';
// import { SYSTEM_IMAGE } from 'src/config';

export default function (props: any) {
  const { scroll, extraHeight } = props;
  const [scrollY, setScrollY] = useState<string>();
  const countRef = useRef(null);
  const handleResize = () => {
    const scrolly = getTableScroll({ ref: countRef, extraHeight });
    setScrollY(scrolly);
  };
  useEffect(() => {
    handleResize();
    window.addEventListener('resize', handleResize);
    return () => window.removeEventListener('resize', handleResize);
  }, [props]);
  const locale = {
    // emptyText: <Empty description="" image={SYSTEM_IMAGE.empty} />,
    emptyText: <Empty description="" image="" />,
  };
  return (
    <div ref={countRef}>
      <Table {...props} scroll={{ x: scroll?.x, y: scrollY }} locale={locale} />
    </div>
  );
}
